home *** CD-ROM | disk | FTP | other *** search
- /*
- File: stdlib.h
-
- Contains: General utilities
-
- Version: Technology: StdCLib 3.4
- Release: 3.6d2
-
- Copyright: © 1987-1996 by Apple Computer, Inc., all rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
-
-
- /*
- * Get common declarations
- */
-
- #ifndef __STDLIB__
- #define __STDLIB__
-
- #ifndef __CONDITIONALMACROS__
- #include <ConditionalMacros.h>
- #endif
- #ifndef __NULLDEF__
- #include <NullDef.h>
- #endif
- #ifndef __SIZETDEF__
- #include <SizeTDef.h>
- #endif
- #ifndef __WCHARTDEF__
- #include <WCharTDef.h>
- #endif
-
-
- #if PRAGMA_ONCE_SUPPORTED
- #pragma once
- #endif /* PRAGMA_ONCE_SUPPORTED */
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #elif PRAGMA_PACK_SUPPORTED
- #pragma pack(push, 2)
- #endif
-
-
-
- struct div_t {
- int quot; /* quotient */
- int rem; /* remainder */
- };
- typedef struct div_t div_t;
-
- struct ldiv_t {
- long quot; /* quotient */
- long rem; /* remainder */
- };
- typedef struct ldiv_t ldiv_t;
-
- #define EXIT_FAILURE 1
- #define EXIT_SUCCESS 0
- #define RAND_MAX 32767
- #define MB_CUR_MAX 1
-
- /*
- * String conversion functions
- */
-
- extern double atof(const char *nptr);
- extern int atoi(const char *nptr);
- extern long atol(const char *nptr);
- extern double strtod(const char *nptr, char **endptr);
- extern long strtol(const char *nptr, char **endptr, int base);
- extern unsigned long strtoul(const char *nptr, char **endptr, int base);
-
- /*
- * Pseudo-random sequence generation functions
- */
-
- extern int rand(void );
- extern void srand(unsigned int seed);
-
- /*
- re-entrant-safe "rand". The function "rand_r" is safe to
- use in re-entrant situations including preemptive
- 68k threads or preemptive tasks provided by the
- Multiprocessing Library for PowerPC/System 7.
-
- To make the prototype for this function visible,
- you must #define _POSIX_THREAD_SAFE_FUNCTIONS 1
- via command-line compiler-directive or equivalent
- option. This function is not available in versions
- of StdCLib prior to 3.5a1.
- */
-
- #if defined(_POSIX_THREAD_SAFE_FUNCTIONS)
- extern int rand_r(unsigned int *seed);
- #endif /* defined(_POSIX_THREAD_SAFE_FUNCTIONS) */
-
-
- /*
- * Memory management functions
- */
-
- extern void *calloc(size_t nmemb, size_t size);
- extern void free(void *ptr);
- extern void *malloc(size_t size);
- extern void *realloc(void *ptr, size_t size);
-
- /*
- * Communication with the environment
- */
-
- typedef void (*_Atexitfuncptr)(void );
- extern void abort(void );
- extern int atexit(_Atexitfuncptr func);
- extern void exit(int status);
- extern char *getenv(const char *name);
- extern int system(const char *str);
-
- /*
- * Searching and sorting utilities
- */
-
- typedef int (*_Cmpfuncptr)(const void *p, const void *q);
- extern void *bsearch(const void *key, const void *base, size_t nmemb, size_t size, _Cmpfuncptr cmpfunptr);
- extern void qsort(void *base, size_t nmemb, size_t size, _Cmpfuncptr cmpfunptr);
-
- /*
- * Integer arithmetic functions
- */
-
- extern int abs(int j);
- extern div_t div( int numer , int denom );
- extern long labs(long j);
- extern ldiv_t ldiv(long numer, long denom);
-
-
- /*
- * Multibyte functions
- */
-
- extern int mblen(const char *s, size_t n);
- extern int mbtowc(wchar_t *pwc, const char *s, size_t n);
- extern int wctomb(char *s, wchar_t wchar);
- extern size_t mbstowcs(wchar_t *pwcs, const char *s, size_t n);
- extern size_t wcstombs(char *s, const wchar_t *pwcs, size_t n);
-
- /*
- * Apple extentions
- */
-
- #if defined(__useAppleExts__) || defined(applec) && !defined(__STDC__) || defined(__PPCC__) && !__STDC__
-
- extern void _exit(int status);
- extern int setenv(const char *varName, const char *value);
- #define putenv(x, y) setenv((x), (y))
-
- #endif /* defined(__useAppleExts__) || (( defined(applec) && ! defined(__STDC__) ) || ( defined(__PPCC__) && !__STDC__)) */
-
-
- #if defined(_LONG_LONG)
- /* Is long long supported? */
-
- struct lldiv_t {
- long long int quot; /* quotient */
- long long int rem; /* remainder */
- };
-
- typedef struct lldiv_t lldiv_t;
-
- extern long long int llabs (long long int j);
- extern lldiv_t lldiv (long long int numer, long long int denom);
- extern long long int strtoll (const char *nptr, char **endptr, int base);
- extern unsigned long long int strtoull (const char *nptr, char **endptr, int base);
- extern long long int atoll (const char *nptr);
-
- #endif /* defined(_LONG_LONG) */
-
-
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #elif PRAGMA_PACK_SUPPORTED
- #pragma pack(pop)
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __STDLIB__ */
-
-